// UnicodeMethod.h: interface for the CUnicodeMethod class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_UNICODEMETHOD_H__79597DE7_BD07_44FD_9E3E_649A9A08DE21__INCLUDED_)
#define AFX_UNICODEMETHOD_H__79597DE7_BD07_44FD_9E3E_649A9A08DE21__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

typedef char		STREAM;

#define TYPE_ANSI				0
#define TYPE_UTF16				1 // Unicode 16 - Little Endian
#define TYPE_UTF8				2 // UTF-8
#define TYPE_UTF16_B			3 // Unicode 16 - Big Endian


//#include "LibUtility.h"
//class LIB_UTILITY_DLLAPI CUnicodeMethod  
class CUnicodeMethod
{
public:
    CUnicodeMethod();
    virtual ~CUnicodeMethod();
    
    
    static int  UnicodeToAnsi(const STREAM* szInput, const int& nInputBytes, 
                              STREAM* szOutput, const int& nOutputBytes, 
                              const int& nInputCodeType = TYPE_UTF16, 
                              const BOOL& bIsNullTerminated = TRUE);
               
               
    static int  AnsiToUnicode(const STREAM* szInput, const int& nInputBytes, 
                              STREAM* szOutput, const int& nOutputBytes, 
                              const int& nOutputCodeType = TYPE_UTF16, 
                              const BOOL& bIsNullTerminated = TRUE);
               
               
    static int  UTF8ToUTF16 (const STREAM* szInput, const int& nInputBytes,
                             STREAM* szOutput, const int& nOutputBytes, 
                             const BOOL& bIsNullTerminated = TRUE);
                           
    static int  UTF16ToUTF8 (const STREAM* szInput, const int& nInputBytes,
                             STREAM* szOutput, const int& nOutputBytes, 
                             const BOOL& bIsNullTerminated = TRUE);

    static int  CheckCodeType   (const STREAM* szInput, const int& nInputBytes, 
                                 int& nBytesBOM);

    static BOOL ToggleEndianType(STREAM* szBuffer, const int& nBytes);

protected:
    static int  _UnicodeToAnsi(const STREAM* szInput, const int& nInputBytes, 
                               STREAM* szOutput, const int& nOutputBytes, 
                               const int& nInputCodeType);

    static int  _AnsiToUnicode(const STREAM* szInput, int nInputBytes, 
                               STREAM* szOutput, const int& nOutputBytes, 
                               const int& nOutputCodeType);
               
    static int  _UTF8ToUTF16  (const STREAM* szInput, int nInputBytes,
                               STREAM* szOutput, const int& nOutputBytes);
               
    static int  _UTF16ToUTF8  (const STREAM* szInput, const int& nInputBytes,
                               STREAM* szOutput, const int& nOutputBytes);
};

#endif // !defined(AFX_UNICODEMETHOD_H__79597DE7_BD07_44FD_9E3E_649A9A08DE21__INCLUDED_)
